    //获取用户名和密码框
let ipt1 = document.querySelector(".reg-body8");
console.log(ipt1);
let ipt2 = document.querySelector(".reg-body15");
console.log(ipt2);



    let isUsername = false;
    let isPassword = false;

    // 失去焦点
ipt1.onblur = function () {
    let reg = /^[a-z]\w{5,17}$/i;
    // 判断正则是否正确
    if (reg.test(ipt1.value)) {
        console.log("满足发起请求");
        console.log(ipt1.value);
            axios.get(checkusernameAPI,{
                params: {username: ipt1.value},
            }).then((res) => {
                let obj = res.data;
                console.log(obj);

                if(obj.code == 1){
                    isUsername=true;
                }else{
                    isUsername=false;
                }
            })
        }else{
            isUsername=false;
        }

}



//失去焦点
ipt2.onblur = function(){
    console.log("失去焦点");
    let reg = /^\S{6,16}$/;
    if(reg.test(ipt2.value)){
        isPassword=true;
    }else{
        isPassword=false;
    }
}



let regClick = document.querySelector(".reg-body20")
console.log(regClick);

regClick.onclick = function(){
    if(isUsername && isPassword){
        let username = ipt1.value;
        let password = ipt2.value;
        axios.get(regAPI,{
            params: {username,password},
        }).then((res)=>{
            let {data}=res;
            console.log(data);
            alert(data.msg);
            if(data.code == 1){
                location.href="login2-登录.html";
            }
        })
    }
}
